﻿////#include<iostream>
////
////class Complex {
////public:
////	Complex(float exi, float abs);
////	void add(Complex* a);
////	void substrate(Complex* a);
////
////	float get_exi() {
////		return this->exi;
////	}
////	float get_abs() {
////		return this->abs;
////	}
////
////protected:
////	float exi = 0;
////	float abs = 0;
////};
////
////Complex::Complex(float exi, float abs) {
////	this->exi = exi;
////	this->abs = abs;
////}
////
////void Complex::add(Complex* a) {
////	exi = exi + a->exi;
////	abs = abs + a->exi;
////}
////
////void Complex::substrate(Complex* b) {
////	exi = exi - b->exi;
////	abs = abs - b->exi;
////}
////
////int main() {
////	Complex *a = new Complex(10.9, 10.0);
////	Complex b(5.0, 5.1);
////
////	a->add(&b);
////
////	std::cout << &b << std::endl;
////	std::cout << a << std::endl;
////	std::cout << &a << std::endl;
////
////	std::cout << "a = " << a->get_exi() << " + " << a->get_abs() << "i\n";
////
////	a->substrate(&b);
////	std::cout << "a = " << a->get_exi() << " + " << a->get_abs() << "i\n";
////
////	delete a;
////
////	return 0;
////}
////
//
//// �����������
//#include<iostream>
//#include<string>
//
//class Rational {
//public:
//	Rational();
//	Rational(int up, int down);
//	Rational operator+(Rational& rhs);
//	Rational operator-(Rational* rhs);
//	Rational operator*(Rational* rhs);
//	Rational operator/(Rational* rhs);
//	int get_up();
//	int get_down();
//	std::string print_result();
//
//protected:
//	int search_min(int a, int b);
//	int search_max(int a, int b);
//	Rational normal(Rational* r);
//
//private:
//	int up;
//	int down;
//
//	// ���ز���������
//	//friend std::ostream& operator<<(std::ostream& os, Rational* f);
//};
//
//Rational::Rational() {
//	this->up = 0;
//	this->down = 1;
//}
//
//Rational::Rational(int up, int down) {
//	this->up = up;
//	this->down = down;
//	std::cout << "address of this pointer:" << this << std::endl;
//}
//
//Rational Rational::operator+(Rational& rhs) {
//	int temp1_up = this->up, temp2_up = rhs.up;
//	int temp_down = this->down;
//
//	if (this->down != rhs.down) {
//		int min = this->search_min(this->down, rhs.down);
//
//		temp1_up *= min / this->down;
//		temp2_up *= min / rhs.down;
//		temp_down = min;
//	}
//
//	Rational temp(temp1_up + temp2_up, temp_down);
//
//	return normal(&temp);
//}
//
//Rational Rational::operator-(Rational* rhs) {
//	int temp1_up = this->up, temp2_up = rhs->up;
//	int temp_down = this->down;
//
//	if (this->down != rhs->down) {
//		int min = this->search_min(this->down, rhs->down);
//
//		temp1_up *= min / this->down;
//		temp2_up *= min / rhs->down;
//		temp_down = min;
//	}
//
//	Rational temp(temp1_up - temp2_up, temp_down);
//
//	return normal(&temp);
//}
//
//Rational Rational::operator*(Rational* rhs) {
//	Rational temp(this->up * rhs->up, this->down * rhs->down);
//
//	return normal(&temp);
//}
//
//Rational Rational::operator/(Rational* rhs) {
//	Rational temp(this->up * rhs->down, this->down * rhs->up);
//
//	return normal(&temp);
//}
//
//int Rational::search_min(int a, int b) {
//	int max = abs(a) > abs(b) ? abs(a) : abs(b);
//
//	while (true) {
//		if ((max % a == 0) && (max % b == 0)) {
//			return max;
//		}
//		else {
//			max++;
//		}
//	}
//}
//
//int Rational::search_max(int a, int b) {
//	for (int min = abs(a) < abs(b) ? abs(a) : abs(b); min >= 2; min--) {
//		if ((a % min == 0) && (b % min == 0)) {
//			return min;
//		}
//	}
//
//	return -1;
//}
//
//Rational Rational::normal(Rational* t) {
//	int max = this->search_max(t->up, t->down);
//
//	if (max == -1) {
//		return *t;
//	}
//	else {
//		return Rational(t->up / max, t->down / max);
//	}
//}
//
//int Rational::get_up() {
//	return this->up;
//}
//
//int Rational::get_down() {
//	return this->down;
//}
//
//std::string Rational::print_result() {
//	if (this->up == 0) {
//		return std::to_string(0);
//	}
//	else if (this->down == 1) {
//		return std::to_string(this->up);  // ʹ��to_string����Ҫ����stringͷ�ļ�
//	}
//	else if (this->down < 0) {
//		return '-' + std::to_string(this->up) + '/' + std::to_string(abs(this->down));
//	}
//	else {
//		return std::to_string(this->up) + '/' + std::to_string(this->down);
//	}
//}
//
////std::ostream& operator<<(std::ostream& os, Rational* f);
//
//int main() {
//	// Rational *num1��*��Ϊ����һ��ָ���¶���thisָ���ָ��
//	Rational* num1 = new Rational(1, 3);  // ��ʾ�������󴴽���ָ������ָ�롣
//	std::cout << "num1:" << num1 << " " << &*num1 << std::endl;
//	Rational* num2 = new Rational(-2, 3);
//	Rational add_num, sub_num, mul_num, del_num;  // ��ʽ�����Ķ���ֱ��ָ����������ķ�����
//
//	add_num = *num1 + *num2;  // �൱�ڷ���һ����ʽ�����Rational����
//	sub_num = *num1 - num2;
//	mul_num = *num1 * num2;
//	del_num = *num1 / num2;
//
//	std::cout << "add_num=" << add_num.print_result() << std::endl;
//	std::cout << "sub_num=" << sub_num.print_result() << std::endl;
//	std::cout << "mul_num=" << mul_num.print_result() << std::endl;
//	std::cout << "del_num=" << del_num.print_result() << std::endl;
//
//	std::cout << num1 << '+' << num2 << "==" << &add_num << std::endl;
//	
//	std::cout << num1 << ',' << &num1 << ',' << &*num1 << std::endl;
//
//	delete num1;
//	delete num2;
//
//	return 0;
//}
//
////std::ostream& operator<<(std::ostream& os, Rational* f) {
////	os << f->up << "/" << f->down;
////
////	return os;
////}
